//
//  IGMylikeViewController.m
//  jingdongfang
//
//  Created by MTiMac02 on 2018/5/7.
//  Copyright © 2018年 BOE-SBG-CTO. All rights reserved.
//

#import "IGMylikeViewController.h"
#import "SliderViewController.h"
#import "IGMyArtistVC.h"
#import "GMyMuseumVC.h"
#import "GMyActivityVC.h"

@interface IGMylikeViewController ()<SliderViewControllerDelegate>
{
    GMyMuseumVC *vc1;
    IGMyArtistVC *vc2;
    GMyActivityVC *vc3;
}
@property (nonatomic, strong)SliderViewController *myLikeSlider;
@end

@implementation IGMylikeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"我的关注";

    if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)])
     {
       self.edgesForExtendedLayout = UIRectEdgeNone;
    }

     _myLikeSlider = [[SliderViewController alloc] initWithFrame:CGRectMake(0, 0, KSCREENWIDTH, KSCREENHEIGHT-NavigationMagin)];
    _myLikeSlider.slideSwitchViewDelegate = self;
    _myLikeSlider.topScrollView.backgroundColor=[UIColor whiteColor];
    _myLikeSlider.tabItemNormalColor = RGB(115, 115, 115);
    _myLikeSlider.tabItemSelectedColor = [UIColor blackColor];
    [self.view addSubview:_myLikeSlider];

     [_myLikeSlider buildUI];
     [self loadModel];
     if (self.index)
      {
    [_myLikeSlider selectIndex:self.index];
      }
}

- (void)setIndex:(NSInteger)index {
    if (_index != index) {
        _index = index;
    }
    if (_myLikeSlider) {
        [_myLikeSlider selectIndex:index];
        [self loadModel];
    }
}
- (void)loadModel
{
    [vc1 viewDidLoad];
    [vc2 viewDidLoad];
    [vc3 viewDidLoad];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(coverWindowClick) name:@"click" object:nil];
    
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"click" object:nil];
}
#pragma mark - SliderViewControllerDelegate

- (NSUInteger)numberOfTab:(SliderViewController *)view {
    return 3;
}

- (UIViewController *)slideSwitchView:(SliderViewController *)view viewOfTab:(NSUInteger)number {
    
    if (number == 0)
    {
        vc1 = [[GMyMuseumVC alloc] init];
        vc1.title = @"艺术馆";
        vc1.nav = self.navigationController;
        return vc1;
    }
    else if (number == 1)
    {
        vc2 = [[IGMyArtistVC alloc] init];
        vc2.title = @"艺术家";
        vc2.nav = self.navigationController;
        return vc2;
    }
    else if (number == 2)
    {
        vc3 = [[GMyActivityVC alloc] init];
        vc3.title = @"活动";
        vc3.nav = self.navigationController;
        return vc3;
    }
    
    return nil;
}

- (void)coverWindowClick
{
    
    if (_myLikeSlider.userSelectedChannelID == 100)
    {
        [vc1 scrollToTOP];
        
    }
    else if (_myLikeSlider.userSelectedChannelID == 101)
    {
        [vc2 scrollToTOP];
    }
    else if (_myLikeSlider.userSelectedChannelID == 102)
    {
        [vc3 scrollToTOP];
    }
    
}
- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
